from pathlib import Path

def delete_pyc_files():
    # 将目录路径转换为 Path 对象
    path = Path().cwd()
    
    # 查找所有 .pyc 文件
    pyc_files = path.rglob('*.pyc')
    
    # 删除所有找到的 .pyc 文件
    for pyc_file in pyc_files:
        try:
            pyc_file.unlink()
            print(f"Deleted: {pyc_file}")
        except Exception as e:
            print(f"Error deleting {pyc_file}: {e}")

if __name__ == "__main__":
    
    # 调用函数删除 .pyc 文件
    delete_pyc_files()
